package com.example.mydefinedview1.ui

import android.content.Context
import android.graphics.Canvas
import android.graphics.Paint
import android.util.AttributeSet
import android.view.View

/**
 *
 * @Author： LJH
 * @Time： 2022/6/29
 * @description：
 */
class PointView(context: Context, attr:AttributeSet?):View(context,attr) {
    private val paint = Paint()

    override fun onDraw(canvas: Canvas?) {
        super.onDraw(canvas)
        //练习内容：使用 canvas.drawPoint() 方法画点
        //一个圆点，一个方点
        //圆点和方点的切换使用 paint.setStrokeCap(cap)：`ROUND` 是圆点，`BUTT` 或 `SQUARE` 是方点
        paint.strokeWidth = 40F
        paint.strokeCap = Paint.Cap.ROUND
        canvas?.drawPoint(300F,200F,paint)
        paint.strokeCap = Paint.Cap.BUTT
        canvas?.drawPoint(500F,200F,paint)

    }
}